package com.api.shopapi.mapper;

import com.api.shopapi.entity.GoodsSizeRemark;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface GoodsSizeRemarkMapper {

    @Insert("insert into goods_size_remark values " +
            "(#{goodsSizeRemark.GoodsSizeRemarkCode},#{goodsSizeRemark.GoodsSizeCode},#{goodsSizeRemark.BusinessCode},#{goodsSizeRemark.Name})")
    int insert(@Param("goodsSizeRemark") GoodsSizeRemark goodsSizeRemark);

    @Update("update goods_size_remark set GoodsSizeCode=#{goodsSizeRemark.GoodsSizeCode},BusinessCode=#{goodsSizeRemark.BusinessCode}," +
            "Name=#{goodsSizeRemark.Name}")
    int update(@Param("goodsSizeRemark") GoodsSizeRemark goodsSizeRemark);

    @Delete("delete from goods_size_remark where GoodsSizeRemarkCode=#{goodsSizeRemarkCode} ")
    int delete(@Param("goodsSizeRemarkCode")String goodsSizeRemarkCode);

    @Select("select * from goods_size_remark where GoodsSizeRemarkCode=#{goodsSizeRemarkCode} limit 1")
    GoodsSizeRemark getByGoodsSizeRemarkCode(@Param("goodsSizeRemarkCode")String goodsSizeRemarkCode);

    @Select("select * from goods_size_remark where BusinessCode=#{businessCode}")
    List<GoodsSizeRemark> getList(@Param("businessCode") String businessCode);

    @Select("<script>" +
            "select * from goods_size_remark " +
            "where BusinessCode=#{businessCode} "+
            "<if test ='name !=null and name!=\"\" '>" +
            "and Name like concat('%',#{name},'%') " +
            "</if>" +
            "</script>")
    List<GoodsSizeRemark> getPageList(@Param("name") String name,@Param("businessCode") String businessCode);
}
